package thesis.filesharing.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.datanucleus.annotations.Unowned;

@Entity
public class Clazz {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Key classKey;
	
	@Basic
	private String classId;
	
	@Basic
	private String className;
	
	@Basic
	private Integer semester;
	
	@ManyToOne
	private Subject subject;
	
	@Unowned
	@ManyToOne
	private Lecturer lecturer;
	
	@Basic(fetch = FetchType.EAGER)
	private Set<Key> studentKeys = new HashSet<Key>();
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "clazz")
	private Set<Group> groups = new HashSet<Group>();
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "clazz")
	private Set<Exercise> exercises = new HashSet<Exercise>();
	
	@Basic
	private Set<Key> documentFileKeys = new HashSet<Key>();
	
	public Clazz() {
		
	}

	public Clazz(String classId, String className, Integer semester) {
		super();
		this.classId = classId;
		this.className = className;
		this.semester = semester;
	}

	public Clazz(String classId, String className, Integer semester, Subject subject) {
		this.classId = classId;
		this.className = className;
		this.semester = semester;
		this.subject = subject;
	}

	public Clazz(Key classKey, String classId, String className, Integer semester, Subject subject) {
		this.classKey = classKey;
		this.classId = classId;
		this.className = className;
		this.semester = semester;
		this.subject = subject;
	}
	
	public Clazz(Key classKey, String classId, String className,
			Integer semester, Subject subject, Lecturer lecturer) {
		this.classKey = classKey;
		this.classId = classId;
		this.className = className;
		this.semester = semester;
		this.subject = subject;
		this.lecturer = lecturer;
	}

	public Clazz(Key classKey, String classId, String className,
			Integer semester, Subject subject, Lecturer lecturer,
			Set<Key> studentKeys) {
		this.classKey = classKey;
		this.classId = classId;
		this.className = className;
		this.semester = semester;
		this.subject = subject;
		this.lecturer = lecturer;
		this.studentKeys = studentKeys;
	}

	public Clazz(Key classKey, String classId, String className,
			Integer semester, Subject subject, Lecturer lecturer,
			Set<Key> studentKeys, Set<Group> groups) {
		this.classKey = classKey;
		this.classId = classId;
		this.className = className;
		this.semester = semester;
		this.subject = subject;
		this.lecturer = lecturer;
		this.studentKeys = studentKeys;
		this.groups = groups;
	}
	
	public Clazz(Key classKey, String classId, String className,
			Integer semester, Subject subject, Lecturer lecturer,
			Set<Key> studentKeys, Set<Group> groups, Set<Exercise> exercises) {
		this.classKey = classKey;
		this.classId = classId;
		this.className = className;
		this.semester = semester;
		this.subject = subject;
		this.lecturer = lecturer;
		this.studentKeys = studentKeys;
		this.groups = groups;
		this.exercises = exercises;
	}

	public Clazz(String classId, String className, Integer semester,
			Subject subject, Lecturer lecturer, Set<Key> studentKeys,
			Set<Group> groups, Set<Exercise> exercises,
			Set<Key> documentFileKeys) {
		this.classId = classId;
		this.className = className;
		this.semester = semester;
		this.subject = subject;
		this.lecturer = lecturer;
		this.studentKeys = studentKeys;
		this.groups = groups;
		this.exercises = exercises;
		this.documentFileKeys = documentFileKeys;
	}

	public Clazz(Key classKey, String classId, String className,
			Integer semester, Subject subject, Lecturer lecturer,
			Set<Key> studentKeys, Set<Group> groups, Set<Exercise> exercises,
			Set<Key> documentFileKeys) {
		this.classKey = classKey;
		this.classId = classId;
		this.className = className;
		this.semester = semester;
		this.subject = subject;
		this.lecturer = lecturer;
		this.studentKeys = studentKeys;
		this.groups = groups;
		this.exercises = exercises;
		this.documentFileKeys = documentFileKeys;
	}

	public Key getClassKey() {
		return classKey;
	}

	public void setClassKey(Key classKey) {
		this.classKey = classKey;
	}

	public String getClassId() {
		return classId;
	}

	public void setClassId(String classId) {
		this.classId = classId;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public Integer getSemester() {
		return semester;
	}

	public void setSemester(Integer semester) {
		this.semester = semester;
	}

	public Subject getSubject() {
		return subject;
	}

	public void setSubject(Subject subject) {
		this.subject = subject;
	}

	public Lecturer getLecturer() {
		return lecturer;
	}

	public void setLecturer(Lecturer lecturer) {
		this.lecturer = lecturer;
	}

	public Set<Key> getStudentKeys() {
		return studentKeys;
	}

	public void setStudentKeys(Set<Key> studentKeys) {
		this.studentKeys = studentKeys;
	}

	public Set<Group> getGroups() {
		return groups;
	}

	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}

	public Set<Exercise> getExercises() {
		return exercises;
	}

	public void setExercises(Set<Exercise> exercises) {
		this.exercises = exercises;
	}

	public Set<Key> getDocumentFileKeys() {
		return documentFileKeys;
	}

	public void setDocumentFileKeys(Set<Key> documentFileKeys) {
		this.documentFileKeys = documentFileKeys;
	}
}
